package com.woniu113.junk.order.controller;


import cn.hutool.core.bean.BeanUtil;
import com.woniu113.junk.commons.model.Result;
import com.woniu113.junk.order.dto.AllOrderLogDTO;
import com.woniu113.junk.order.form.AllOrderLogForm;
import com.woniu113.junk.order.model.OrderLog;
import com.woniu113.junk.order.param.AllOrderLogParam;
import com.woniu113.junk.order.service.OrderLogService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 蜡笔没了小新
 * @since 2024年10月16日
 */
@RestController
@RequestMapping("/orderLog")
public class OrderLogController {
    @Resource
    private OrderLogService orderLogService;

    @PostMapping("/findAll")
    @ApiOperation(value = "查询所有订单日志")
    private Result<List<OrderLog>> findAll(@RequestBody AllOrderLogForm form){
        System.out.println("分页数据1"+form.getPageNum());
        System.out.println("分页数据2"+form.getPageSize());
        System.out.println("身份"+form.getUserType());
        // 计算查询的起始索引
        int offset = (form.getPageNum() - 1) * form.getPageSize();
        AllOrderLogDTO dto = orderLogService.findAll(BeanUtil.toBean(form, AllOrderLogParam.class),offset);
        Integer total = dto.getTotal();
        return Result.getListResult(OrderLog.class).setData(dto.getList()).setMsg("查询所有订单日志成功").setCode(200).setTotal(dto.getTotal());
    }
}

